package com.taylor.nio;

import java.nio.IntBuffer;

/**
 * @Desc : nio 组件buffer
 * @Author ： taylor
 * @Date ：2021/6/25 23:48
 */
public class BufferDemo {
    public static void main(String[] args) {
        IntBuffer buffer = IntBuffer.allocate(10);

        for (int i = 0; i < buffer.capacity(); i++) {
             buffer.put(i+2);
        }
        //buffer 读写切换
        buffer.flip();

        while (buffer.hasRemaining()){

            System.out.println(buffer.get());
        }
    }
}
